package cn.zjutleo.village_server.controller;

import cn.zjutleo.village_server.entity.AddressData;
import cn.zjutleo.village_server.service.RedisService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @Author: 杜雨茜
 * @Description: 该类用于 测试redis
 */
@Api(tags = "Redis测试类")
@RestController
@RequestMapping("/RedisTest")
public class testRedisController {
    @Autowired
    RedisService redisService;

    @GetMapping("/test1")
    public void testRedis(){
        AddressData addressData=new AddressData();
        addressData.setCode("code");
        addressData.setName("code");
        redisService.set("redisTestKey3",addressData);
        redisService.set("redisTestKey2","addressData");
        redisService.set("redisTestKey","addressData",5);
        String value="redisTestValue";
        System.out.println(redisService.get("redisTestKey"));
    }
    @GetMapping("/test2")
    public Object testRedis2(){
        return redisService.get("redisTestKey");
    }

}
